package com.wing.productionPlan.controller.admin;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.wing.common.utils.PageResult;
import com.wing.enterprise.feign.EnterpriseClient;
import com.wing.enterprise.sell.model.entity.Order;
import com.wing.enterprise.sell.model.response.OrderVO;
import com.wing.productionPlan.service.ProductionPlanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@Validated
@Api(value = "Admin-生产计划-正式订单列表", tags = "#/productionPlan/formalOrder")
@RestController("FormalOrderController")
@RequestMapping("productionPlan/admin/formalOrder")
@RequiredArgsConstructor
public class FormalOrderController {
    @Autowired
    private EnterpriseClient enterpriseClient;

    @ApiOperation(value = "查询所有正式订单列表", notes = "搜索")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "第几页", defaultValue = "1", example = "1", dataType = "Integer", paramType = "query")
            ,@ApiImplicitParam(name = "limit", value = "每页多少条", defaultValue = "10", example = "10", dataType = "Integer", paramType = "query")
            ,@ApiImplicitParam(name = "sort", value="排序字段名", defaultValue = "create_time", example = "create_time", dataType = "String", paramType = "query")
            ,@ApiImplicitParam(name = "order", value="排序规则(asc:正序, desc:倒序)", defaultValue = "desc", example = "asc", dataType = "String", paramType = "query")
            ,@ApiImplicitParam(name = "code", value="订单编号", dataType = "String", paramType = "query")
            ,@ApiImplicitParam(name = "status", value="signed(6,已签约);finish(7,完成);", dataType = "String", paramType = "query")
            ,@ApiImplicitParam(name = "orderSource", value="订单来源:staff(0,自主录入/员工录入);platform(1,云端制造/平台指派);agent(2,渠道录入/代理商录入);customer(3,云端智采/客户直接委派)", dataType = "String", paramType = "query")
            ,@ApiImplicitParam(name = "orderType", value="订单类型:proff(0,打样订单);trial(1,试产订单);mass(2,量产订单)", dataType = "String", paramType = "query")
    })
    @GetMapping("/list")
    public PageResult<OrderVO> list(
            @RequestParam(defaultValue = "1") Integer page
            ,@RequestParam(defaultValue = "10") Integer limit
            ,@RequestParam(defaultValue = "create_time") String sort
            ,@RequestParam(defaultValue = "asc") String order
            , String code
            , Order.Status status
            , Order.OrderSource orderSource
            , Order.OrderType orderType
            ,Integer whetherList

    ){
        PageResult<OrderVO> pageList = enterpriseClient.getOrderPageList(page, limit, sort, order, code, status, orderSource, orderType,whetherList);
        return new PageResult<>(pageList.getData(), pageList.getCount());
    }

}
